﻿using Newtonsoft.Json.Linq;
using System.Collections;
using System.Collections.Generic;

namespace LD.BC
{
    public interface IBoardCard
    {
        Dictionary<string, string[]> GetParam();

        #region 连接
        void Connection();
        /// <summary>
        /// 关闭指定的板卡，释放资源
        /// </summary>
        /// <param name="boardCardId"></param>
        void Closed();
        #endregion

        #region 参数初始化
        /// <summary>
        /// 载入config文档
        /// </summary>
        /// <param name="fileName"></param>
        void LoadConfig(string fileName);
        /// <summary>
        /// 加载机种信息
        /// </summary>
        /// <param name="partNo"></param>
        void DownAxisParam();
        #endregion

        #region 轴信息
        /// <summary>
        /// Get轴位置
        /// </summary>
        /// <param name="axis"></param>
        /// <returns></returns>
        double GetAxisPosition(ushort axis);
        /// <summary>
        /// Set轴位置
        /// </summary>
        /// <param name="axis"></param>
        void SetAxisPosition(ushort axis, double position);
        /// <summary>
        /// 轴运动信号状态
        /// </summary>
        /// <param name="cardNo"></param>
        /// <param name="axis"></param>
        /// <returns>2进制字符串</returns>
        string GetAxisStatus(ushort cardNo, ushort axis);
        /// <summary>
        /// 设置正负限位
        /// </summary>
        /// <param name="cardNo">板卡</param>
        /// <param name="axis">轴</param>
        /// <param name="n_limit">负限位</param>
        /// <param name="p_limit">正限位</param>
        void SetSoftLimit(ushort cardNo, ushort axis, int n_limit, int p_limit);
        /// <summary>
        /// 设置脉冲当量
        /// </summary>
        /// <param name="cardNo">板卡</param>
        /// <param name="axis">轴</param>
        /// <param name="equiv">脉冲量</param>
        void SetEquiv(dynamic cardNo, ushort axis, double equiv);
        /// <summary>
        /// 获取脉冲当量
        /// </summary>
        /// <param name="cardNo"></param>
        /// <param name="axis"></param>
        /// <returns></returns>
        double GetEquiv(ushort cardNo, ushort axis);
        #endregion

        #region 轴动作

        /// <summary>
        /// 停止单轴
        /// </summary>
        /// <param name="axis"></param>
        void Stop(ushort axis);
        /// <summary>
        /// 急停
        /// </summary>
        /// <param name="axis"></param>
        void StopALL();
        /// <summary>
        /// 轴移动，
        /// </summary>
        /// <param name="axis"></param>
        /// <param name="direction">方向：0/反方向，1/正方向</param>
        void Move(ushort axis, ushort direction);
        /// <summary>
        /// 定量移动（相对）
        /// </summary>
        /// <param name="axis">轴</param>
        /// <param name="direction">方向：0/反方向，1/正方向</param>
        /// <param name="ration_v">定量值</param>
        void Move_Ration(ushort axis, ushort direction, double ration_v);
        void Move_Ration(ushort axis, double ration_v);
        /// <summary>
        /// 坐标移动
        /// </summary>
        /// <param name="axis">轴</param>
        /// <param name="location">坐标</param>
        void Move_Location(ushort axis, double location);
        /// <summary>
        /// 回原点
        /// </summary>
        /// <param name="axis"></param>
        void Move_BackZero(ushort axis);
        /// <summary>
        /// 回零成功否
        /// </summary>
        /// <param name="axis"></param>
        /// <returns></returns>
        bool GetHomeStatus(ushort axis);
        /// <summary>
        /// 等轴运行结束
        /// </summary>
        /// <param name="cardNo"></param>
        /// <param name="axis"></param>
        void WaitAxisComplete(ushort axis);
        /// <summary>
        /// 等轴运行结束
        /// </summary>
        void WaitAxisComplete();
        /// <summary>
        /// 是否运动中
        /// </summary>
        /// <returns></returns>
        bool IsMoving();
        /// <summary>
        /// 设置轴参数
        /// </summary>
        /// <param name="plus"></param>
        void SetAxisParam(ushort axis, TB_AxisParam model);
        /// <summary>
        /// 设置使能
        /// </summary>
        /// <param name="isEnabled"></param>
        void SetSevon(ushort axisId, bool isEnabled);
        /// <summary>
        /// 所有轴开启使能
        /// </summary>
        /// <param name="axisId"></param>
        /// <param name="isEnabled"></param>
        void SetSevonAll(bool isEnabled);
        /// <summary>
        /// 清除轴报警
        /// </summary>
        /// <param name="axisId"></param>
        void ClearAlart(ushort axisId);
        #endregion

        #region IO
        /// <summary>
        /// 设置out
        /// </summary>
        /// <param name="outPos"></param>
        /// <param name="low_high"></param>
        void SetOut(ushort outPos, ushort low_high);
        int GetOut(int outPos);
        int GetIn(int outPos);
        List<int> GetIn();
        List<int> GetOut();
        /// <summary>
        /// 获取轴ALM报警信息
        /// </summary>
        /// <param name="axisId"></param>
        /// <returns></returns>
        AlmModel GetAlm(ushort axisId);
        /// <summary>
        /// 设置alm信息
        /// </summary>
        /// <param name="axisId"></param>
        /// <param name="enable"></param>
        /// <param name="val"></param>
        /// <returns></returns>
        int SetAlm(ushort axisId, ushort enable, ushort val);
        #endregion

        #region 监控
        void Start();
        #endregion
    }
}
